#include "categoryinfo.h"

CategoryInfo::CategoryInfo() {}

bool CategoryInfo::writeXML(const QXmlStreamWriter &writer){
    return true;
}

bool CategoryInfo::ReadXML(QXmlStreamReader &reader){
    //QXmlStreamReader::TokenType token = reader.readNext();
    QString className = reader.name().toString();

    QXmlStreamAttributes attributes = reader.attributes();
    if(attributes.hasAttribute("key")) {
        m_nKey = attributes.value("key").toInt();
    }

    m_strName = reader.readElementText();
    return true;
}

QJsonObject CategoryInfo::toJson(){
    QJsonObject obj;
    obj["Key"] = this->m_nKey;
    obj["Name"] = this->m_strName;
    return obj;
}

void CategoryInfo::fromJson(QJsonObject obj){
    this->m_nKey = obj["IPAddress"].toInt();
    this->m_strName = obj["Name"].toString();
}

